package cn.b504.qpcr.controller;

import cn.b504.qpcr.entity.AjaxResult;
import cn.b504.qpcr.entity.User;
import cn.b504.qpcr.interfaces.UserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户系统后台接口
 */
@RestController
@RequestMapping("user")
public class UserController {
  private final UserService userService;

  public UserController(UserService userService) {
    this.userService = userService;
  }

  // 获取用户列表
  @RequestMapping("getUserLists")
  public AjaxResult getUserLists() {
    return userService.getUserLists();
  }

  // 登陆
  @RequestMapping("loginAction")
  public AjaxResult login(@RequestBody User user) {
    return userService.login(user);
  }

  @RequestMapping("addNewUser")
  public AjaxResult addNewUser(@RequestBody User user) {
    return userService.addNewUser(user);
  }

  @RequestMapping("modifyUser")
  public AjaxResult modifyUser(@RequestBody User user) {
    return userService.modifyUser(user);
  }

  @RequestMapping("deleteUser")
  public AjaxResult deleteUser(@RequestBody String id) {
    return userService.deleteUser(id);
  }
}